//字符串
let str:string = 'hello';
//数字
let num:number = 123;
//布尔
let bool:boolean = true;
//打印
console.log(str,num,bool);
//字面量类型
function printText(s:string,align:'left'|'right'|'center'){
    console.log(s,align);
}
printText( 'hello', 'left')
//定义接口
interface IPerson{
    name:string;
    age:number;
    sex?:boolean;//当前属性为可选
}
//定义变量指定类型
let person1:IPerson = {
    name:'张三',
    age:18,
    sex:true
}
let person2:IPerson = {
    name:'张三',
    age:18,
}
//定义一个类使用class关键字
class User{
    name:string;
    age:number;
    //构造方法
    constructor(name:string,age:number){
        this.name = name;
        this.age = age;
    }
    //普通方法
    study(){
        console.log(this.name+'在学习');
    }
}
//使用User类型
const user = new User('张三',18);
//定义接口
interface IUser{
    name:string;
    age:number;
    study():void;
}
//定义一个类实现接口
class Student implements IUser{
    name:string;
    age:number;
    constructor(name:string,age:number) {
        this.name = name;
        this.age = age;
    }
    study(){
        console.log(this.name+'在学习');
    }
}
//创建类型为Bird类型的对象
const zs=new Student('张三',18)
zs.study()
//继承Student类
class Teacher extends Student{
    teach(){
        console.log(this.name+'在教学');
    }
    study(){
        console.log(this.name+'在教学');
    }
}
const ls=new Teacher( '李四', 18)
ls.study()
ls.teach()